# 连接静态库
#[[ cmake_minimum_required(VERSION 3.0)
project(CALC)
file(GLOB SRC_LIST ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#指定连接库目录
link_directories(${PROJECT_SOURCE_DIR}/lib)

#连接静态库
link_libraries(calc)
add_executable(app ${SRC_LIST})
# add_library(calc_shared SHARED ${SRC_LIST})
# add_library(calc STATIC ${SRC_LIST})
]]

# 连接动态库
cmake_minimum_required(VERSION 3.0)
project(CALC)
file(GLOB SRC_LIST ${PROJECT_SOURCE_DIR}/src/*.c)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
file(GLOB HEAD_LIST ${PROJECT_SOURCE_DIR}/include/*.h)

list(APPEND SRC_PATH ${SRC_LIST} ${HEAD_LIST})
message(STATUS "字符串拼接 list ${SRC_PATH}")

# 移除src里面的main.c
list(REMOVE_ITEM SRC_LIST ${PROJECT_SOURCE_DIR}/src/main.c)
message(STATUS "移除后的列表 ${SRC_LIST}")

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

#指定动态库的位置
link_directories(${PROJECT_SOURCE_DIR}/lib)

# 输出一般日志信息
message(STATUS "source path: ${PROJECT_SOURCE_DIR}")
# 输出警告信息
message(WARNING "source path: ${PROJECT_SOURCE_DIR}")
# 输出错误信息
message(FATAL_ERROR "source path: ${PROJECT_SOURCE_DIR}")


add_executable(app ${SRC_LIST})

# 动态连接库，连接系统pthread及自定的动态库 lib+库命+.so 前后缀会自动加上不用管
# 连接动态库的时候要放在可执行编译之后才行
target_link_libraries(app pthread calc_shared)

#[[字符串拼接 set方式
set(TEMP "hello,world")
file(GLOB SRC_1 ${PROJECT_SOURCE_DIR}/src1/*.cpp)
file(GLOB SRC_2 ${PROJECT_SOURCE_DIR}/src2/*.cpp)
# 追加(拼接)
set(SRC_1 ${SRC_1} ${SRC_2} ${TEMP})
message(STATUS "message: ${SRC_1}")
]]

#[[字符串拼接 list 方式
cmake_minimum_required(VERSION 3.0)
project(TEST)
set(TEMP "hello,world")
file(GLOB SRC_1 ${PROJECT_SOURCE_DIR}/src1/*.cpp)
file(GLOB SRC_2 ${PROJECT_SOURCE_DIR}/src2/*.cpp)
# 追加(拼接)
list(APPEND SRC_1 ${SRC_1} ${SRC_2} ${TEMP})
message(STATUS "message: ${SRC_1}")
]]